package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.zzw.TAppManage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TAppManageMapper;
import com.ruoyi.system.service.ITAppManageService;

/**
 * 应用Service业务层处理
 *
 * @author xbx
 * @date 2023-10-20
 */
@Service
public class TAppManageServiceImpl extends ServiceImpl<TAppManageMapper, TAppManage> implements ITAppManageService {
    @Autowired
    private TAppManageMapper tAppManageMapper;

    /**
     * 查询应用
     *
     * @param cAppId 应用主键
     * @return 应用
     */
    @Override
    public TAppManage selectTAppManageByCAppId(Long cAppId) {
        return tAppManageMapper.selectTAppManageByCAppId(cAppId);
    }

    /**
     * 查询应用列表
     *
     * @param tAppManage 应用
     * @return 应用
     */
    @Override
    public List<TAppManage> selectTAppManageList(TAppManage tAppManage) {
        return tAppManageMapper.selectTAppManageList(tAppManage);
    }

    /**
     * 新增应用
     *
     * @param tAppManage 应用
     * @return 结果
     */
    @Override
    public int insertTAppManage(TAppManage tAppManage) {
        Long aLong = tAppManageMapper.selectId();
        tAppManage.setcAppId(aLong + 1);
        return tAppManageMapper.insertTAppManage(tAppManage);
    }

    /**
     * 修改应用
     *
     * @param tAppManage 应用
     * @return 结果
     */
    @Override
    public int updateTAppManage(TAppManage tAppManage) {
        return tAppManageMapper.updateTAppManage(tAppManage);
    }

    /**
     * 批量删除应用
     *
     * @param cAppIds 需要删除的应用主键
     * @return 结果
     */
    @Override
    public int deleteTAppManageByCAppIds(List<Long> cAppIds) {
        return tAppManageMapper.deleteTAppManageByCAppIds(cAppIds);
    }

    /**
     * 删除应用信息
     *
     * @param cAppId 应用主键
     * @return 结果
     */
    @Override
    public int deleteTAppManageByCAppId(Long cAppId) {
        return tAppManageMapper.deleteTAppManageByCAppId(cAppId);
    }

    @Override
    public List<TAppManage> listByDistrict(String districtId) {
        QueryWrapper<TAppManage> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(StringUtils.isNotBlank(districtId), TAppManage::getcAppDistrictId, districtId)
                ;
        return this.list(queryWrapper);
    }
}
